<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="icon"
    href="https://aoxin.enn.cn/api/ops/pageconfig/getbrowsericon?temp=Wed%20Apr%2020%202022%2013%3A12%3A21%20GMT+0800%20%28%u4E2D%u56FD%u6807%u51C6%u65F6%u95F4%29"
    type="image/x-icon">
  <title>title</title>

  <style>
    /* reset start */
    html,
    body {
      margin: 0;
      padding: 0;
    }

    p:not(.not-indent),
    h2:not(.not-indent),
    h3:not(.not-indent),
    h4:not(.not-indent) {
      text-indent: 32px;
    }

    @media print {
      @page {
        margin: 20px;
      }
    }

    body {
      width: 817px;
      margin: 0 auto;
      font-size: 16px;
      line-height: 22px;
    }

    /* reset start */

    /* 基础类 start */
    .bold {
      font-weight: 700;
    }

    .red {
      color: #f00;
    }

    .indent {
      text-indent: 32px;
    }

    .ul {
      /* 下划线 */
      text-decoration: underline;
      text-decoration-color: rgb(227, 3, 251);
      text-underline-offset: 3px;
    }

    .pre-line {
      /* 自动换行，并保留空格 */
      white-space: pre-line;
    }

    .fl {
      float: left;
    }

    .fr {
      float: right;
    }

    .overflow-hidden {
      overflow: hidden;
    }
    /* 基础类 end */

    .opt-btn {
      position: fixed;
      z-index: 999;
    }

    .title {
      text-align: center;
      line-height: 45px;
    }

    /* .el-table {
      border: 2px solid var(--el-table-border-color) !important;
    } */

    .el-textarea {
      margin: 5px 0;
    }

    .el-textarea.red .el-textarea__inner,
    .el-textarea__inner::placeholder {
      color: #f00;
    }

    /* 删除输入框中的下划线 */
    .el-textarea.ul {
      text-decoration: unset;
    }

    .signature {
      display: flex;
      height: 80px;
    }

    .signature .person {
      width: 50%;
    }

    .principal {
      height: 80px;
      padding-right: 100px;
    }
  </style>

  <script src="https://unpkg.com/dayjs@1.11.1/dayjs.min.js"></script>

  <!-- 生产 -->
  <!-- <script src="https://cdn.fanneng.com/statics/vue/3.2.33/vue.global.prod.js"></script> -->
  <!-- 开发 -->
  <script src="https://unpkg.com/vue@3.2.33/dist/vue.global.js"></script>

  <!-- enn element-plus -->
  <link rel="stylesheet" href="https://static.dev.ennew.com/statics/@enn/element-plus/dist/2.0.0-beta.3/index.css" crossorigin="anonymous">
  <script src="https://static.dev.ennew.com/statics/@enn/element-plus/dist/2.0.0-beta.3/index.full.min.js" crossorigin="anonymous"></script>

  <!-- element-plus -->
  <!-- <link rel="stylesheet" href="https://unpkg.com/element-plus@2.1.11/dist/index.css"></link>
  <script src="https://unpkg.com/element-plus@2.1.11/dist/index.full.min.js"></script> -->

  <script src="https://unpkg.com/axios@0.18.1/dist/axios.min.js"></script>

  <!-- print-js -->
  <!-- <script src="https://printjs-4de6.kxcdn.com/print.min.js"></script>
  <link rel="stylesheet" href="https://printjs-4de6.kxcdn.com/print.min.css"></link> -->
</head>

<body>
  <div id="app" class="container">
    <span v-loading.fullscreen.lock="loading"></span>

    <div class="opt-btn" v-if="!isDownload">
      <el-button type="primary" plain round @click="isPreview = !isPreview">{{isPreview ? '编辑' : '预览'}}</el-button>

      <template v-if="isPreview">
        <el-button type="success" plain round @click="saveData">保存</el-button>
        <el-button color="rgb(227, 3, 251)" plain round @click="enterDownload">下载</el-button>
      </template>
    </div>

    <h1 class="title" id="title">
      <span class="ul">{{enterpriseName}}</span><br>
      <span class="ul">{{reportYear}}</span>年信用等级评级报告及综合授信尽职调查报告
    </h1>

    <p>
      <span class="ul">{{enterpriseName}}</span>为我公司新增客户，根据《新奥财务有限责任公司综合授信业务管理办法》的规定，对<span class="ul">{{enterpriseName}}</span>拟评定为<span
        class="ul">{{grade}}</span>级。同时按照有关规定，我公司对申请人的经营情况、财务状况、信用需求及担保情况、综合信用风险等情况进行了调查分析，拟同意对申请人授信额度<span class="ul">{{recLimit}}万</span>，期限<span
        class="ul">{{sugDuration}}</span>。
    </p>

    <p>
      <span class="bold">调查路径：</span>通过企业提供的贷款申请与申请人财务主管等相关人员座谈了解企业的经营、财务状况、信用需求等情况，补充销售预测及其他相关情况，撰写并充实调查报告。
    </p>

    <p>
      <span class="bold">调查方式：</span>采用走访公司业务部门主管及财务主管等方式了解企业经营及财务等情况；对申请人的总体情况进行了汇总分析。承诺本调查报告所涉及的相关情况属实，对所调查和分析情况的客观真实性负责。
    </p>

    <h2>一、公司概况</h2>

    <h3>1.基本概况</h3>

    <div>
      <p>
        <span class="ul">{{enterpriseGeneralize.name}}</span>位于<span
          class="ul">{{enterpriseGeneralize.address}}</span>，{{enterpriseGeneralize.termStart}}取得<span
          class="ul">{{enterpriseGeneralize.belongOrg}}</span>颁发的注册号为<span class="ul">{{enterpriseGeneralize.regNo}}</span>营业执照，法定代表人<span
          class="ul">{{enterpriseGeneralize.operName}}</span>，营业期限自<span class="ul">{{enterpriseGeneralize.termStart}}</span>至<span
          class="ul">{{enterpriseGeneralize.termEnd}}</span>。公司注册资本金<span class="ul">{{enterpriseGeneralize.registCapi}}</span>，<enn-input class="red"
          :is-preview="isPreview" v-model="enterpriseGeneralize.registCapiNote"></enn-input>
        <span>经营范围<span class="ul">{{enterpriseGeneralize.scope}}</span></span>
      </p>

      <!-- 法定代表人 -->
      <p>
        法定代表人<enn-input class="ul" :is-preview="isPreview" v-model="enterpriseGeneralize.legalRepresentativeDetail"></enn-input>
      </p>

      <p>
        公司一号位<enn-input class="ul" :is-preview="isPreview" v-model="enterpriseGeneralize.companyNoOneDetail"></enn-input>
      </p>

      <p>
        财务负责人<enn-input class="ul" :is-preview="isPreview" v-model="enterpriseGeneralize.financePrincipalDetail"></enn-input>
      </p>
    </div>

    <h2>二、客户资信情况</h2>

    <h3>1.信用状况</h3>

    <enn-pre-input class="red" :is-preview="isPreview" v-model="creditStandingDetail.creditDetail"></enn-pre-input>

    <h3>2.对外担保情况</h3>

    <enn-pre-input class="red" :is-preview="isPreview" v-model="creditStandingDetail.externalSecurityDetail"></enn-pre-input>

    <h2>三、公司财务情况</h2>

    <h3>1.资产负债表</h3>

    <div>
      <el-table :data="financialDetail.assetLiabilityInfo.assetLiability" stripe>
        <el-table-column prop="instrName" label="项目"></el-table-column>
        <el-table-column prop="value2" :label="financialDetail.beforeLastYear + '年（万元）'"></el-table-column>
        <el-table-column prop="value1" :label="financialDetail.lastYear + '年（万元）'"></el-table-column>
        <el-table-column prop="value" :label="financialDetail.baseYear + '年（万元）'"></el-table-column>
        <el-table-column prop="radio" label="变动比率（较上年）"></el-table-column>
      </el-table>

      <p>资产规模及资产结构变动：</p>

      <p>
        流动资产合计为<span class="ul">{{financialDetail.assetLiabilityInfo.currentAssets}}</span>万元，占资产总额的比重为<span
          class="ul">{{financialDetail.assetLiabilityInfo.currentAssetsProportion}}</span>，流动资产合计较上年增长<span
          class="ul">{{financialDetail.assetLiabilityInfo.currentAssetsRadio}}</span>。
      </p>

      <p>非流动资产合计为<span class="ul">{{financialDetail.assetLiabilityInfo.nonCurrentAssets}}</span>万元，非流动资产合计较上年增长<span
          class="ul">{{financialDetail.assetLiabilityInfo.nonCurrentAssetsRadio}}</span>。
      </p>

      <p class="not-indent">主要科目变动情况，主要科目判定选标准为：</p>

      <p class="ul" v-for="(item, index) of financialDetail.assetLiabilityInfo.subjectChangeInfo" :key="index">{{item}}</p>

      <p>
        固定资产<enn-input class="ul" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.fixedAssetsDetail"></enn-input>
      </p>

      <p>
        长期股权投资情况<enn-input class="ul" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.longTermEquityInvestmentDetail"></enn-input>
      </p>

      <p>
        长期负债情况<enn-input class="ul" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.longTermLiabilitiesDetail"></enn-input>
      </p>
    </div>

    <h4>（1）应收账款</h4>

    <div>
      <p>
        应收账款为<span class="ul">{{financialDetail.assetLiabilityInfo.accountsReceivable}}</span>万元,较上年增长<span
          class="ul">{{financialDetail.assetLiabilityInfo.accountsReceivableRadio}}</span>。应收账款占流动资产比重为<span
          class="ul">{{financialDetail.assetLiabilityInfo.accountsReceivableProportion}}</span>。
        <enn-input class="ul" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.accountsReceivableNote"></enn-input>
      </p>

      <p>主要行业的应收账款近3年变动情况：</p>

      <enn-pre-input class="ul" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.threeYearsAccountsReceivableNote"></enn-pre-input>

      <p>前5大应收账款客户变动情况：</p>

      <el-table :data="financialDetail.assetLiabilityInfo.bigFiveAccountsReceivable" stripe>
        <el-table-column prop="customerName" label="客户名称"></el-table-column>
        <el-table-column prop="busAreaTxt" label="业务范围"></el-table-column>
        <el-table-column prop="sumReceivables" label="总额"></el-table-column>
        <el-table-column prop="receivables30" label="1-30天"></el-table-column>
        <el-table-column prop="receivables1year" label="1年以内"></el-table-column>
        <el-table-column prop="receivables3year" label="1-3年"></el-table-column>
        <el-table-column prop="receivables3yearMore" label="3年以上"></el-table-column>
      </el-table>
    </div>

    <h4>（2）固定资产及在建工程</h4>

    <div>
      <p>
        固定资产为<span class="ul">{{financialDetail.assetLiabilityInfo.fixedAssets}}</span>万元，占非流动资产的比重为<span
          class="ul">{{financialDetail.assetLiabilityInfo.fixedAssetsProportion}}</span>，固定资产较上年增长<span
          class="ul">{{financialDetail.assetLiabilityInfo.fixedAssetsRadio}}</span>。
        <enn-input class="red" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.fixedAssetsNote"></enn-input>
      </p>
    </div>

    <h4>（3）长期股权投资</h4>

    <p>
      长期股权投资余额为<span class="ul">{{financialDetail.assetLiabilityInfo.longTermEquityInvestment}}</span>万元。
      <enn-input class="red" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.longTermEquityInvestmentNote" placeholder="请输入内容" />
    </p>

    <h4>（4）应付账款</h4>

    <div>
      <p>
        应付账款为<span class="ul">{{financialDetail.assetLiabilityInfo.accountsPayable}}</span>万元,较上年增长<span
          class="ul">{{financialDetail.assetLiabilityInfo.accountsPayableRadio}}</span>。剔除应付内部公司款项影响，应付账款余额为<span
          class="ul">{{financialDetail.assetLiabilityInfo.accountsPayable}}</span>万元。
      </p>

      <p>主要行业的应付账款近3年变动情况：</p>

      <enn-pre-input class="ul" :is-preview="isPreview" v-model="financialDetail.assetLiabilityInfo.threeYearsAccountsPayableNote"
        placeholder="请输入内容"></enn-pre-input>

      <p>前5大应付账款客户变动情况：</p>

      <el-table :data="financialDetail.assetLiabilityInfo.bigFiveAccountsPayable" stripe>
        <el-table-column prop="customerName" label="客户名称"></el-table-column>
        <el-table-column prop="busAreaTxt" label="业务范围"></el-table-column>
        <el-table-column prop="sumReceivables" label="总额"></el-table-column>
        <el-table-column prop="receivables30" label="1-30天"></el-table-column>
        <el-table-column prop="receivables1year" label="1年以内"></el-table-column>
        <el-table-column prop="receivables3year" label="1-3年"></el-table-column>
        <el-table-column prop="receivables3yearMore" label="3年以上"></el-table-column>
      </el-table>
    </div>

    <h3>2.损益表</h3>

    <div>
      <el-table :data="financialDetail.profitLossInfo.profitLoss" stripe>
        <el-table-column prop="instrName" label="项目"></el-table-column>
        <el-table-column prop="value2" :label="financialDetail.beforeLastYear + '年（万元）'"></el-table-column>
        <el-table-column prop="value1" :label="financialDetail.lastYear + '年（万元）'"></el-table-column>
        <el-table-column prop="value" :label="financialDetail.baseYear + '年（万元）'"></el-table-column>
      </el-table>

      <p>
        营业收入为<span class="ul">{{financialDetail.profitLossInfo.businessIncome}}</span>万元，营业收入较上年增长<span
          class="ul">{{financialDetail.profitLossInfo.businessIncomeRadio}}</span>，营业成本为<span
          class="ul">{{financialDetail.profitLossInfo.businessCosts}}</span>万元，营业成本较上年增长<span
          class="ul">{{financialDetail.profitLossInfo.businessCostsRadio}}</span>。
        <enn-input class="red" :is-preview="isPreview" v-model="financialDetail.profitLossInfo.businessNote" />
      </p>
    </div>

    <h3>3.现金流量表</h3>

    <el-table :data="financialDetail.cashFlow" stripe>
      <el-table-column prop="instrName" label="项目"></el-table-column>
      <el-table-column prop="value2" :label="financialDetail.beforeLastYear + '年（万元）'"></el-table-column>
      <el-table-column prop="value1" :label="financialDetail.lastYear + '年（万元）'"></el-table-column>
      <el-table-column prop="value" :label="financialDetail.baseYear + '年（万元）'"></el-table-column>
    </el-table>

    <h3>4.财务指标</h3>

    <el-table :data="financialDetail.financialMetricsInfo.financialMetrics" stripe>
      <el-table-column prop="instrName" label="项目"></el-table-column>
      <el-table-column prop="value2" :label="financialDetail.beforeLastYear + '年（万元）'"></el-table-column>
      <el-table-column prop="value1" :label="financialDetail.lastYear + '年（万元）'"></el-table-column>
      <el-table-column prop="value" :label="financialDetail.baseYear + '年（万元）'"></el-table-column>
    </el-table>

    <p class="bold">财务指标分析</p>

    <p>主要财务指标分析</p>

    <h4>（1）偿债能力分析：</h4>

    <div>
      <p>
        公司资产负债率为<span class="ul">{{financialDetail.financialMetricsInfo.assetLiabilityRatio}}</span>，
        <enn-input class="red" :is-preview="isPreview" v-model="financialDetail.financialMetricsInfo.assetLiabilityRatioNote"></enn-input>
        负债水平较前一年度下降<span class="ul">{{financialDetail.financialMetricsInfo.assetLiabilityRatioIncrease}}</span>。
      </p>
      <p>
        流动比率为<span class="ul">{{financialDetail.financialMetricsInfo.currentRatio}}</span>，速动比率为<span
          class="ul">{{financialDetail.financialMetricsInfo.quickRatio}}</span>，
        <enn-input class="red" :is-preview="isPreview" v-model="financialDetail.financialMetricsInfo.currentRatioNote"
          placeholder="currentRatioNote" />
      </p>
      <p>经营现金净流量对流动负债的保障倍数为<span class="ul">{{financialDetail.financialMetricsInfo.coverageRatio}}</span>。</p>
    </div>

    <h4>（2）盈利能力分析：</h4>

    <div>
      <p>总资产报酬率为<span class="ul">{{financialDetail.financialMetricsInfo.returnOnTotalAssets}}</span>，
        <enn-input class="red" :is-preview="isPreview" v-model="financialDetail.financialMetricsInfo.returnOnTotalAssetsNote"
          placeholder="returnOnTotalAssetsNote" />
      </p>
      <p>销售利润率为<span class="ul">{{financialDetail.financialMetricsInfo.salesProfitMargin}}</span>，
        <enn-input class="red" :is-preview="isPreview" v-model="financialDetail.financialMetricsInfo.salesProfitMarginNote"
          placeholder="salesProfitMarginNote" />
      </p>
    </div>

    <h4>（3）营运能力分析：</h4>

    <div>
      <p>应付账款周转率为<span class="ul">{{financialDetail.financialMetricsInfo.accountsPayableTurnoverRate}}</span>；</p>

      <p>存货周转率为<span class="ul">{{financialDetail.financialMetricsInfo.inventoryTurnoverRate}}</span>；</p>

      <enn-pre-input class="red" :is-preview="isPreview" v-model="financialDetail.financialMetricsInfo.operationalCapacityAnalysis"
        placeholder="operationalCapacityAnalysis"></enn-pre-input>
    </div>

    <h2>四、经营情况及资金需求预测</h2>

    <enn-pre-input class="red" :is-preview="isPreview" v-model="businessDemandForecast.forecastNote" placeholder="forecastNote"></enn-pre-input>

    <h3>1.固定资产投资情况：</h3>

    <div>
      <p>存量资产置换:
        <enn-input class="ul" :is-preview="isPreview" v-model="businessDemandForecast.replacementStockAssets" placeholder="replacementStockAssets" />
      </p>
      <p>新增固定资产投资:
        <enn-input class="ul" :is-preview="isPreview" v-model="businessDemandForecast.newFixedAssetInvestmen" placeholder="newFixedAssetInvestmen" />
      </p>
      <p>固定资产建设资金缺口:
        <enn-input class="ul" :is-preview="isPreview" v-model="businessDemandForecast.capitalGapFixedAssetsConstruction"
          placeholder="capitalGapFixedAssetsConstruction" />
      </p>
    </div>

    <h3>2.上游供应商情况分析</h3>

    <enn-pre-input class="red" :is-preview="isPreview" v-model="businessDemandForecast.upstreamSuppliers"></enn-pre-input>

    <h3>3.天然气销售客户中</h3>

    <div>
      <p>行业分布</p>
      <p>前5大客户：行业、账期、现金回款比(业务逻辑待沟通)</p>
      <p>
        因：预计整体天然气采购量增加（手工录入）亿方，导致整体气费采购资金增加（手工录入）亿元；同时上游气费预付周期缩短，增加预付资金（手工录入）亿元，下游客户应收账款回收周期拉长，需增加周转资金（手工录入）亿元。
      </p>
    </div>

    <h3>4.流动资金需求测算（监管）</h3>

    <enn-pre-input :is-preview="isPreview" v-model="businessDemandForecast.workingFundCalculate "></enn-pre-input>

    <h2>五、信用等级、授信额度</h2>

    <div>
      <el-descriptions :column="4" border>
        <el-descriptions-item>
          <template #label>生态位:</template>
          {{ baseInfo.niche }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template #label>评级:</template>
          {{ baseInfo.grade  }}
        </el-descriptions-item>
        
        <el-descriptions-item>
          <template #label>建议额度:</template>
          {{ baseInfo.recLimit }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template #label>建议期限:</template>
          {{ baseInfo.sugDuration }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template #label>总评分:</template>
          {{ baseInfo.totalScore }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template #label>调整系数:</template>
          {{ baseInfo.adjustCoeff }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template #label>结余现金流:</template>
          {{ baseInfo.balanceCashFlow }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template #label>评级更新时间:</template>
          {{ baseInfo.gradeTime }}
        </el-descriptions-item>
      </el-descriptions>

      <p>根据《新奥财务有限责任公司环境风险审核指引》和《绿色产业指导目录》，该企业属于绿色产业，评级不下调。</p>
      <p>经人行征信管理系统查询，公司没有未结清不良信贷信息和欠息记录。信用良好。</p>

      <p>用信要求及用信条件</p>

      <p>流动资金：
        <enn-input class="ul" :is-preview="isPreview" v-model="creditGradeAndQuota.workingFund" placeholder="workingFund" />
      </p>
      <p>固定资产贷款：
        <enn-input class="ul" :is-preview="isPreview" v-model="creditGradeAndQuota.fixedAssetsLoan" placeholder="fixedAssetsLoan" />
      </p>
      <p>财务公司承兑汇票：
        <enn-input class="ul" class="red" :is-preview="isPreview" v-model="creditGradeAndQuota.acceptanceBill" />
      </p>
    </div>

    <h2>六.风险性分析及风险控制措施</h2>

    <div>
      <p>公司经营中面临的风险主要有：</p>

      <enn-pre-input class="red" :is-preview="isPreview" v-model="riskAnalyseAndControlVo.mainRiskNote"></enn-pre-input>

      <p>主要风险控制措施：</p>

      <enn-pre-input class="red" :is-preview="isPreview" v-model="riskAnalyseAndControlVo.riskMeasuresNote"></enn-pre-input>
    </div>

    <h2>七.综合结论</h2>

    <p>满足新奥财务公司<span class="ul">{{grade}}</span>级客户测评标准。拟同意将该企业评定为<span class="ul">{{grade}}</span>级客户。</p>
    <p>经调查认为该公司主体资格合法，经营情况正常，信用记录良好。<span class="ul">{{reportYear}}</span>年拟为该公司授信<span class="ul">{{recLimit}}</span>万元，期限<span
        class="ul">{{sugDuration}}</span>。</p>

    <p>以上情况，请审查。</p>

    <div>
      <p class="signature">
        <span class="person">调查人：</span>
        <span class="person">复核人：</span>
      </p>

      <p class="overflow-hidden"><span class="fr">{{date}}</span></p>
    </div>

    <div>
      <p style="padding-bottom: 80px;">客户服务群负责人意见：</p>

      <p class="overflow-hidden"><span class="fr principal">客户服务群负责人签字：</span></p>
      <div class="overflow-hidden"><span class="fr">{{date}}</span></div>
    </div>
  </div>

  <script>
    const search = new URLSearchParams(location.search);
    const reportYear = search.get('reportYear') ?? '2021';
    const enterpriseName = search.get('enterpriseName') ?? '福建新奥能源发展有限公司';
    const creditNo = search.get('creditNo') ?? '9113100060134700XG';
    document.title = `${enterpriseName}-授信报告`;

    // axios实例
    const request = axios.create({
      baseURL: 'http://10.39.38.13:8000', // 开发环境
      timeout: 5000
    })

    const { ElMessage } = ElementPlus;
    const { createApp, defineComponent, computed, ref, toRef, toRefs, onMounted, onBeforeUnmount, nextTick } = Vue;

    // 根组件 setup 函数
    const setup = () => {
      const loading = ref(false);

      const creditReport = ref({
        reportYear: "",
        creditNo: "",
        enterpriseName: "",
        grade: "",
        recLimit: "",
        sugDuration: "",
        enterpriseGeneralize: {},
        creditStandingDetail: {
          creditDetail: "",
          externalSecurityDetail: ""
        },
        financialDetail: {
          baseYear: "",
          lastYear: "",
          beforeLastYear: "",
          assetLiabilityInfo: {
            assetLiability: [],
            currentAssets: "",
            currentAssetsProportion: "",
            currentAssetsRadio: "",
            nonCurrentAssets: "",
            nonCurrentAssetsRadio: "",
            subjectChangeInfo: [],
            fixedAssetsDetail: "",
            longTermEquityInvestmentDetail: "",
            longTermLiabilitiesDetail: "",
            accountsReceivable: "",
            accountsReceivableRadio: "",
            accountsReceivableProportion: "",
            bigFiveAccountsReceivable: [],
            fixedAssets: "",
            fixedAssetsRadio: "",
            fixedAssetsProportion: "",
            longTermEquityInvestment: "",
            accountsPayable: "",
            accountsPayableRadio: "",
            bigFiveAccountsPayable: []
          },
          profitLossInfo: {
            profitLoss: [],
            businessIncome: "",
            businessIncomeRadio: "",
            businessCosts: "",
            businessCostsRadio: ""
          },
          cashFlow: [],
          financialMetricsInfo: {
            financialMetrics: [],
            assetLiabilityRatio: "",
            assetLiabilityRatioIncrease: "",
            currentRatio: "",
            quickRatio: "",
            returnOnTotalAssets: "",
            salesProfitMargin: "",
            accountsPayableTurnoverRate: "",
            inventoryTurnoverRate: ""
          }
        },
        businessDemandForecast: {},
        creditGradeAndQuota: {},
        riskAnalyseAndControlVo: {},
        inquirer: "",
        reviewer: "",
        reviewDate: "",
        accountManagerOpinion: "",
        accountManagerSignature: "",
        signatureDate: ""
      });

      const queryData = async () => {
        try {
          loading.value = true;

          const { data: { success, data, message } } = await request.post('/companyReport/queryCreditReportInfo', { reportYear, creditNo });

          if (!success) {
            return ElMessage.warning(message);
          }

          // 必须使用这种方式合并，不能直接=赋值覆盖原对象
          creditReport.value = Object.assign(creditReport.value, data);
        } catch (error) {
          console.log(error);
          ElMessage.warning(error.message);
        } finally {
          loading.value = false;
        }
      };

      queryData();

      const saveData = async () => {
        try {
          loading.value = true;

          const { data: { success, data, message } } = await request.post('/companyReport/saveCreditReportInfo', creditReport.value);

          if (!success || !data) {
            return ElMessage.warning(message);
          }

          ElMessage.success(`保存成功`);
        } catch (error) {
          console.log(error);
        } finally {
          loading.value = false;
        }
      };

      const isPreview = ref(false) // 是不是预览模式
      const isDownload = ref(false) // 是不是下载模式

      // 进入下载模式
      const enterDownload = () => {
        isDownload.value = true;
        nextTick(() => window.print());
      }

      // 退出下载模式
      const quitDownload = () => (isDownload.value = false);

      // 添加打印后事件函数
      onMounted(() => window.addEventListener('afterprint', quitDownload));
      // 移除打印后事件函数
      onBeforeUnmount(() => window.removeEventListener('afterprint', quitDownload));

      return {
        date: dayjs().format('YYYY年MM月DD日'),
        isDownload,
        isPreview,
        autosize: { minRows: 2 },
        loading,
        ...toRefs(creditReport.value),
        // 信用等级、授信额度 基本信息
        baseInfo: computed(() => {
          const data = {...creditReport.value.creditGradeAndQuota.ratingDetailVo};
          
          if (data.recLimit === undefined) {
            data.recLimit = '暂无数据';
          } else if (data.totalScore > 0 && data.recLimit > 0) {
            data.recLimit = data.recLimit + '万';
          } else {
            data.recLimit = '不建议';
          }
          
          data.balanceCashFlow = typeof data.balanceCashFlow === "number"
              ? data.balanceCashFlow + "万"
              : data.balanceCashFlow;

          // 空值赋予默认值 "暂无数据"
          Reflect.ownKeys(data).forEach(key => (data[key] = data[key] ?? "暂无数据"));

          return data;
        }),
        enterDownload,
        saveData
      }
    }

    // 包含预览功能的输入框组件
    const EnnInput = defineComponent({
      template: `<span v-if="isPreview" :class="$attrs.class">{{$attrs.modelValue}}</span><el-input v-else type="textarea" :placeholder="placeholder" :autosize="autosize"></el-input>`,
      props: {
        isPreview: {
          type: Boolean,
          required: true
        },
      },
      setup: () => ({ placeholder: "请输入内容", autosize: { minRows: 2 } })
    })

    // 包含预览功能的输入框组件, 如果有换行符以多段落形式展示
    const EnnPreInput = defineComponent({
      template: `<p v-if="isPreview" :class="$attrs.class" v-for="(text, index) of ($attrs.modelValue || '').split(/\\n/)" :key="index + new Date().getTime()">{{text}}</p><el-input v-else type="textarea" :placeholder="placeholder" :autosize="autosize"></el-input>`,
      props: {
        isPreview: {
          type: Boolean,
          required: true
        },
      },
      setup: () => ({ placeholder: "请输入内容", autosize: { minRows: 2 } })
    })

    createApp({ setup })
      .use(ElementPlus)
      .component('enn-input', EnnInput)
      .component('enn-pre-input', EnnPreInput)
      .mount('#app');
  </script>
</body>

</html>